{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<center><strong>A Journey Into Math For Machine Learning</strong></center>\n",
    "<center><strong>机器学习之数学之旅</strong></center>\n",
    "<center><strong>图解极大似然估计$(maximum \\ likelihood \\ estimation \\ with \\ 3D \\ visualization)$</strong></center>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window.Plotly) {{require(['plotly'],function(plotly) {window.Plotly=plotly;});}}</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window.Plotly) {{require(['plotly'],function(plotly) {window.Plotly=plotly;});}}</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from scipy import stats\n",
    "import plotly.graph_objs as go\n",
    "from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\n",
    "from IPython.display import Image \n",
    "init_notebook_mode(connected=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "def draw_likelihood(observations, mu, sigma):\n",
    "    # 定义y轴取值\n",
    "    plt.ylim(-0.02,1)\n",
    "    # 定义一个画图范围\n",
    "    x_locs =  np.linspace(-10, 10, 500)\n",
    "    # 画出推断的概率分布的概率密度函数\n",
    "    plt.plot(x_locs, stats.norm.pdf(x_locs, loc=mu, scale=sigma), label=\"inference\")\n",
    "    for obs in observations:\n",
    "        plt.axvline(x=obs, ymin=0, ymax=stats.norm.pdf(obs, loc=mu, scale=sigma)+0.01, c=\"g\")\n",
    "    plt.axvline(x=obs, ymin=0, ymax=stats.norm.pdf(obs, loc=mu, scale=sigma)+0.01, c=\"g\", label=\"probabilities\")\n",
    "    # 画出观测数据的概率\n",
    "    plt.scatter(x=observations, y=[0 for _ in range(len(observations))], c=\"r\", marker=\"o\", label=\"obsevations\")\n",
    "    plt.legend()\n",
    "    plt.grid()\n",
    "    plt.title(\"mean={} sigma={}\".format(str(mu), str(sigma)))\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**极大似然估计**是神经网络和很多复杂模型得以优化求解的理论基础, 我们今天来学习并试着深入理解极大似然估计的原理和推导, 最后我们对极大似然估计进行3D可视化, 建立一种直观的认识.\n",
    "   \n",
    "要理解**极大似然估计**是什么, 首先要明白**概率密度(质量)函数**是什么, 如果你不知道的话, 那就简短解释一下：   \n",
    "概率密度函数用来描述某个随机变量取某个值的时候，取值点所对应的的**概率**$(probability)$的函数.   \n",
    "如下图, 我们现在有一个**概率分布**, 属于**正态分布**: $$X \\sim N(\\mu,\\sigma^2), \\quad  f(x;\\mu,\\sigma)=\\frac{1}{\\sigma\\sqrt{2\\pi}} \\, \\exp \\left( -\\frac{(x- \\mu)^2}{2\\sigma^2} \\right)$$\n",
    "\n",
    "其中$\\mu$是均值, $\\sigma$是标准差. 如果你不熟悉正态分布, 我们简单回顾一下$\\mu$指的是均值, 在下图中, 均值是$0$则正态分布的概率在均值处概率最高, 以均值为中心两边是对称的,  $\\sigma$是标准差, 标准差控制着概率分布偏离均值的程度, 标准差越大概率分布越扁平, 越小的话, 概率分布越集中于均值.   \n",
    "   \n",
    "我们另有一个**数据点**, 是一个**随机变量**, 取值$2.5$, 我们将$x=2.5$代入$f(x;\\mu=5,\\sigma=2)$得出下图出中绿色直线的长度, 也就是得到了$P(x=2.5 \\mid \\mu=5, \\sigma=2)$    \n",
    "意义为$x=2.5$在上面定义的正态分布中的概率, 也就是给定一个概率分布, 随机变量在这个概率分布中出现的可能性, 而$f(x;\\mu,\\sigma)=\\frac{1}{\\sigma\\sqrt{2\\pi}} \\, \\exp \\left( -\\frac{(x- \\mu)^2}{2\\sigma^2} \\right)$就是概率密度函数.   \n",
    "概率质量函数是离散的, 概率密度函数是连续的, 意义相同, 为了可视化的方便, 今天用概率密度函数来讲解极大似然估计."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEICAYAAACktLTqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8VPW9//HXJwmEQDBhE4EgQWWHsIQtIBpUKlIVrbivqEW06PW2LmDdt59evdZqsbR1r9QIWhDRXlCEiig7yCoS1oQqsiSQECAk+f7+mEkcQpbJOsnx/Xw8hpzlO2c+c2Z4z5nvmfmOOecQERFvCQt1ASIiUv0U7iIiHqRwFxHxIIW7iIgHKdxFRDxI4S4i4kEKd5FKMLP1ZpYc6jpESqNwl58V83nWzPb5L8+amVV0O865Hs65BTVQYrUws3vNbJ2ZZZnZNjO7N9Q1Se2KCHUBIrVsHHAJ0BtwwKfANmBKKIuqAQbcAKwBTgfmmlmacy4ltGVJbdGRu1SJmW33HyWuMbNDZvaambU2s3/5jxo/M7NmAe0Hm9lXZpZpZt8Edm2Y2Vgz2+i/3lYzuy1gXbKZpZvZ78zsRzP73szGVqLkG4H/dc6lO+d2Af8L3FTKfWtpZrP9te43s4VmFhZwv8/zT0eZ2VtmluGv/z4zS6/CPppuZj+Y2QEz+8LMelT0Tjrn/sc5t9I5l+ec2wR8CAyt6Hak/lK4S3W4DBgBdAYuAv4FPAC0wvccuwvAzNoBHwNPAs2Be4APzKyVfzs/AhcCJwFjgT+YWb+A2zkFiAHaAbcAkwtD0cwm+kO4xEvANnoA3wTMf+NfVpLfAen++9Haf59KGq/jESAeOM2/H66r7D7y+xfQCTgZWAlMLVxRgftJwHUMGAasL+V+ihc553TRpdIX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uv9xjsH33KpRZtYAX7BPdc79s/j6wLB3zn1iZq+YWUvnXI0OkBXE41Ijz6kgXQCsdM7tLr4iVPsrwG4za+Oc+97fTfVjCW124Ts3UCgO3/nGSquP3TKzgKv8n2ToiO8VeGlgA39ozMc3tjz4xpqvqXcC5wHfOufSS1ppZk3MrGnhNL6TiutKaltdivVzXlrK7QUzTn911zUSuA+42DmXU0qb2tpfdfJ3Cvx9+q8BG51zL5TS5pTCvn8zG4jv/3GNvugE+bjMAm7wf2pmMHAgoDuippX67jkU+6uYwOdRaVk0B/iFmTXzd6P+wr+s8mrjDHJlLvhCKR04Cuzm+F+D+j2+TzpsAi4IWP4J0NY/fRq+0E8FpgORNVTnm8D4YsvaAp8E1PGN/7IeX/dETe+7vwNrgTX+J1ab4nX550fh+zTGllqqKxVfv+Jq/2VK8bpqc3+VdP+Bx/G9+IDvF+Km++teCpxWC/voTHzdaWsC9tMoYHzh8wyY4N833+A7MT2kFuoq8XEpVpcBk/37cy0Bn3Kr4dqa4AvrmIBlIdlf+F5gvgeO+fPrFnznaeYBm4HPgOb+tv2BVwOue7P/uZYKjK1qLRp+QETEg+pjt4yIiJRD4S4i4kEKdxERD1K4i4h4kMJdRMSDFO4iIh6kcBcR8aD/D8eGUrIYLmm/AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "draw_likelihood([2.5], mu=0, sigma=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**概率**和**似然**的区别:   \n",
    "**概率**，是在已知一些概率分布参数的情况下，预测观测的结果；   \n",
    "**似然**，则是用于在已知某些观测所得到的结果时，对观测结果所属于的的概率分布的参数进行估值。\n",
    "   \n",
    "**极大似然估计**的目的在于找到一个最符合当前观测数据的概率分布.   \n",
    "1. 我们先理解似然函数是什么\n",
    "例如下面两图中: **红色圆点**指的是观测到的随机变量, **蓝色的线**是概率密度函数的图像, **绿色的直线**的**长度**所对应的$y$轴的值指的是是观测的数据出现在当前概率分布中的可能性, 也就是概率, 概率是介于$[0，1]$之间的实数, 我们用$P(x \\mid \\mu,\\sigma)$来表示绿色线的长度, 也就是概率.   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEICAYAAACktLTqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl4VNX9x/H3Nws7RAQEIUBQEYEQtrAEVGILghalCLjhAmrRUrT+bG2l7rhUK3UtiChWrFSFUhFxQUQimwiIyBJkEaIEZZE1EQIkOb8/ZpKGkGQmIWQml8/reebJ3Dvnnvudw+STy507Z8w5h4iIeEtEqAsQEZHyp3AXEfEghbuIiAcp3EVEPEjhLiLiQQp3EREPUriLlIGZrTWz5FDXIVIchbucUszsITM7amaZBW5nlbYf51xb51zKSSixXJjZ3Wa2xswyzGyLmd0d6pqkYkWFugCREHjbOXddqIs4yQy4AVgFnA18bGZbnXNvhbYsqSg6cpcTYmZp/qPEVWb2s5lNMrOGZvah/6jxEzOrW6B9dzNbbGb7zOzrgqc2zGy4ma3zb7fZzG4t8FiymaWb2R/MbKeZ/Whmw0/yc6tvZrP8te4xswVmFlHgeff2369uZpPNbK+//j+ZWfoJjNE0M9tuZvvNbL6ZtS1t7c65vznnVjjnsp1z64F3gZ4nPipSWSjcpTwMAvoA5wKXAR8CfwEa4HuN3QFgZk2A94FHgdOBPwLTzayBv5+dQH+gDjAceMbMOhXYTyMgBmgC3AyMywtFM7vHH8JF3grVe5k/rNea2W9LeF5/ANL9z6Oh/zkVNV/Hg0AccJZ/HIr6X0FQY+T3IdASO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759efXVV/PPe2/bto2dO3ce16579+4sWrSITZs2AfDzzz+zYcOGEvvu06cP48aNy1/eu3dvmfqpSAp3EfGEiy++mGuvvZakpCTatWvH4MGDycjIOK5dgwYNeO2117jmmmtISEggKSkp/43T4tx3333s3buX+Ph42rdvz7x5847rp3fv3gH7qUgBv0P1ZNGXdZx8GqfANEZFW7duHa1bt85fDrdTDuHoZIxR4X8HADP70jmXGGhbHbmLiHiQwl1ExIMU7iIiHqRwFxHxIIW7iIgHKdxFRDxI4S4inpScnExpLrd+7bXXGDVqVJGP5U0/nJaWRnx8PADLly/njjvuAHyX1H7xxRf57SdMmMDrr79e1tLLhaYfEJFKKycnp1wnNCtOUdMPJyYmkpjou9w8JSWF6OhoevfuDcBtt9120msKREfuIhKW0tLS8qf4bd26NYMHD+bgwYPExcXx5z//mU6dOjFt2jRWrlxJ9+7dSUhIYODAgezduze/j3/961906NCB+Ph4li5dCsDSpUtJSkqiY8eO9OjRg/Xr1+e337p1K8nJybRs2ZKHH344f33e9MMFpaSk0L9/f9LS0pgwYQLjxo2jQ4cOLFiwgIceeoixY8cC8O2339KvXz86d+7MBRdckP8p1mnTpuV/4vXCCy8s9/HTkbuIlOjOj+7ky21flusRcodGHXi237MB261fv55JkybRs2dPbrrpJsaPHw9AvXr1WLFiBQAJCQm88MIL9OrViwceeICHH36YZ5/19X3w4EFWrlzJ/Pnzuemmm1izZg3nnXceCxYsICoqik8++YS//OUv+fOzL126lDVr1lCjRg26dOnCr371q/yj8+LExcVx2223ER0dzb333gvA3Llz8x8fMWIEEyZMoGXLlnzxxReMHDmSTz/9lDFjxjB79myaNGnCvn37Sj+IASjcRSRsNW3aNH8a3euuu47nn38egKuuugqA/fv3s2/fPnr16gXAjTfeyJAhQ/K3v+aaawC48MILOXDgAPv27SMjI4Mbb7yRjRs3YmYcPXo0v32fPn2oV68e4Jv6d+HChQHDvSSZmZksXrz4mJoOHz4MQM+ePRk2bBhXXnll/jTD5UnhLiIlerbfsyGbW8bMilwuOIV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LYmYDgReABsD7ZrbSOdfXP7/8VHxf2p0N/M45lxPKWsPE38ysA77TMmnAraEtJ3wU9z0FIS4r3DQE3jHfdylGAf92zn0U2pLCg5m9CSQD9c0sHXgQeAKYamY345vO/MrQVajpB0REPMkrp2VERKQAhbuIiAcp3EVEPEjhLiLiQQp3EREPUriLiHiQwl1ExIP+H2iorF7WNZpuAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEICAYAAACktLTqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8leWd///Xh+x72LcEghUVjCEIAhEXnIFKrcpYcbdu7VDraMdfW6dS6lKrHR0dtTo61J/2IVaqg2O1VG1FrRkRq4gaZBNZjCZhD9lD9uv7x31yPIQk5yQEEm7ez8fjPHLu+1z3dV/nysk797nOfa7bnHOIiIi/9OvtBoiISM9TuIuI+JDCXUTEhxTuIiI+pHAXEfEhhbuIiA8p3EW6wczWmdmM3m6HSEcU7nJUMc99ZlYauN1nZtbVepxzJzrn8g9BE3uUmcWa2QYzK+7ttsjhFd3bDRA5zOYB/wRMABzwBvAFsLA3G3UI3QLsBlJ6uyFyeOnIXQ6KmRWa2S1m9qmZ1ZjZU2Y21Mz+YmZVZvammfUPKT/NzN4zs3IzWx06tGFm1waOMqvMbKuZ/SDksRlmVmxmPzGzXWa23cyu7UaTrwb+0zlX7JwrAf4TuKaD5zbIzF4JtHWvmS03s34hz3tm4H6CmS0ys7JA+/8t9Ei5G330gpntMLMKM3vHzE7sxvPEzMYAVwL/3p3t5cimcJeecCEwCzgOOA/4C/BzYDDea+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06dMBaGhoIC8vL1jPd77zHQAmTZrEH//4RwDefPNNnn/++WCZ/v3788orr+xXT11dXfB+X6BwF5FO3XHeib3+Jaa4uLjg/aioKJqamg4o45xj/vz5/OAHP9hvfWFhIUlJSfuVmzVrFs8991yn++poPx3V09t91JbG3EXEF84++2x+97vfBce9S0pK2LVr1wHlpk2bxooVK9i8eTMANTU1fP75553WPWvWLB577LHgcllZWbfqOZwU7iLiC9/85je5/PLLycvL46STTmLu3LlUVVUdUG7w4ME8/fTTXHbZZeTk5JCXlxf84LQjv/jFLygrKyM7O5sJEybw9ttvH1DPzJkzw9ZzOIW9huqhoot1HHrqp/DUR+3bsGED48aNCy73tSGHvuhQ9FHb3wOAmX3knJscblsduYuI+JDCXUTEhxTuIiI+pHAXEfEhhbuIiA8p3EVEfEjhLiK+NGPGDLpyuvXTTz/NjTfe2O5jrdMPFxYWkp2dDcCqVav40Y9+BHin1H7wwQfB8gsXLuSZZ57pbtN7hKYfEJEjVnNzc49OaNaR9qYfnjx5MpMne6eb5+fnExMTw8yZMwG4/vrrD3mbwtGRu4j0SYWFhcEpfseNG8fcuXOpra0lKyuLn/3sZ5x88sm88MILFBQUMG3aNHJycrjgggsoKysL1vH73/+e3NxcsrOzWblyJQArV64kLy+PiRMncuqpp7Jx48Zg+aKiImbMmMHYsWP55S9/GVzfOv1wqPz8fM4991wKCwtZuHAhjz32GLm5uSxfvpw777yTBx54AIAtW7Ywe/ZsJk2axOmnnx78FusLL7wQ/MbrGWec0eP9pyN3EenUzX+9mY9KPurRI+TcYbk8PPvhsOU2btzIU089xfTp07nuuut4/PHHARg4cCAff/wxADk5OTz66KOceeaZ3H777fzyl7/k4Ye9umtraykoKOCdd97huuuuY+3atZxwwgksX76c6Oho3nzzTX7+858H52dfuXIla9euJTExkVNOOYVvf/vbwaPzjmRlZXH99dcTExPDggULAHjrrbeCj8+bN4+FCxcyduxYPvjgA2644Qb+9re/cdddd/H6668zcuRIysvLu96JYSjcRaTPyszMDE6je+WVV/LII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5OWzatKlH+qqtSCYOGwmETnpQDExtU+ZOYJmZ3QQkATPbq8jM5gHzAIYOHUp+fn4Xm+uprq7u9rZHE/VTeOqj9qWlpe03V0pzc3O7c6cARC9ZQvxNN2H79nkrvvwS98//TF1dHU0XX9ztNnzyySc89dRTvPXWWzjn+Id/+AcmT57Mxo0befTRR1m4cCE33HADDz30EFdccQUvvvgiH330EWYWnP3xhhtu4Ac/+AF5eXkUFRVxwQUXsGrVKr71rW/x3HPPceWVV/Lhhx+SkZFBYmIiEyZM4I033sDMWLRoEXfffTe//vWvufbaa0lOTg5eeem1114jJiaGqqoqrrzySu6//37y8vL493//dxYsWMB9991Hc3MztbW1vPXWW7z++uvcfvvtLF26lEceeYR58+ZxySWX0NDQ0Gnf1tXVdf/16Zzr9AbMBZ4MWf4u8F9tyvwY+Engfh6wHujXWb2TJk1y3fX22293e9ujifopPPVR+9avX7/fcmVlZceFR492Dg68jR59UG14+OGH3W233RZc/sUvfuF+85vfuMzMzOC6t956y82ZM8c1Nja6nJwcd+2117oXX3zR1dfXO+ecGzx4sJswYULwNmLECFdVVeVWrFjhzj77bOecczfffLN74oknnHPOffrpp27WrFkuOzvbHXfcccEyd9xxh7v//vuD+21dLi8vD7ansrLSbd682U2cONE559yZZ57p3n33Xeecczt27HDf+MY3nHPOLV682I0fP97de++97vPPP++0D9r+HpxzDljlwuS2cy6iYZkSIDNkOSOwLtT3gCWBfxZ/B+KBQd37dyMiR5Svvura+oPU3rS80dHRrFy5krlz5/LKK68we/ZswJty9/3336egoICCggJKSkpITk4mLy+PzZs3s3v3bl5++eXgfOo33XQTN954I2vWrOG3v/0tdXV1B9XWuLg4AKKiooKTlF1++eUsXbqUhIQEzjnnHP72t78d1D46Ekm4fwiMNbMxZhYLXAosbVPmK+AfAcxsHF647+7JhopIHzVqVNfWR+j000/n5Zdfpra2lpqaGl566SVOP/30dqcBrq6upqKignPOOYeHHnooOK3uN7/5TR599NFgna3zqpsZF1xwAT/+8Y8ZN25ccB710OmAF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5Wb1NUOBlwIXjI8G/uCc+2vnmxwdzOw5YAYwyMyKgTuAe4ElZvY9vOnML+69Fmr6ARERX/LLsIyIiIRQuIuI+JDCXUTEhxTuIiI+pHAXEfEhhbuIiA8p3EVEfOj/AcEADm3+sdNiAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "obs_mu, obs_sigma = 0, 4\n",
    "observations = np.random.normal(obs_mu, obs_sigma, 20)\n",
    "draw_likelihood(observations, mu=5, sigma=2)\n",
    "draw_likelihood(observations, mu=0, sigma=4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. 我们假设有一组观测到的数据, 一共有$N$个, $X_{observation} = \\{ x_1, x_2, ... , x_N\\}$   \n",
    "我们推断这一组数据属于一个概率分布, 是一个正态分布, 它的概率密度函数为$f(x;\\mu,\\sigma)$, 我们将$X_{observation}$里的数据点带入到$f(x;\\mu,\\sigma)$里, 得到每个数据点在我们假设的概率分布中的出现的可能性, 注意我们接下来简写$X_{observation}$为$X$:\n",
    "$$P(x_1 \\mid \\mu,\\sigma), \\,P(x_2 \\mid \\mu,\\sigma)\\, , ... \\, ,\\,P(x_N \\mid \\mu,\\sigma)$$\n",
    "3. 那么这一组数据$X_{observation} = \\{ x_1, x_2, ... , x_N\\}$在假设的概率分布中的出现的可能性就是他们概率的乘积:\n",
    "$$L(\\mu ,\\sigma \\mid X)=P(X \\mid \\mu ,\\sigma)=\\prod _{i=1}^{N}P(x_{i}\\mid \\mu,\\sigma)$$\n",
    "上式中, 我们用$L(\\mu ,\\sigma \\mid X)$来表示似然函数, 已知的观测到的数据点$X$, 用似然函数$L(\\mu ,\\sigma \\mid X)$来估计参数$\\mu ,\\sigma$的可能性, 由此可见，似然函数也是一种条件概率函数，但我们关注的变量改变了.   \n",
    "   \n",
    "4. 从下面两图可得, 上图图中所假设的概率分布求出的似然函数取值显然比下面的小, 因为有很接近于$0$的数值, 这让似然函数乘积的结果变得非常小. 我们可以得出结论, 下图的概率分布参数更符合观测到的数据点的概率分布,而**最大似然估计**的目的就是找到一个最符合当前数据的分布的参数."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们做个试验:\n",
    "1. 先从均值为$0$, 标准差为$4$正态分布中随机抽取$200$个数据点, 作为我们观测到的数据;\n",
    "之后我们定义一个估计参数的取值范围, 均值在$(-0.5, 0.5)$之间, 标准差在$(3.5, 4.5)$之间;   \n",
    "2. 然后我们将所有的数据点和我们估计的每一组参数代入似然函数, 也就是$L(\\mu ,\\sigma \\mid X)=\\prod _{i=1}^{N}P(x_{i}\\mid \\mu,\\sigma)$中, 求得每一组参数的似然值, 3.下图可见, 似然函数的值约在$\\mu=0, \\ \\sigma=4$时取得极大值(因为数据点太少有些误差);\n",
    "4. 我们发现似然函数的图像是凸函数, 我们就可以用很多优化的方法求它的极大值了.\n",
    "5. 找到似然函数极大值的过程就是极大似然估计的过程."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 首先定义观测的数据分布, 我们定一个一个均值为0, 标准差为4的正态分布, \n",
    "# 并从中随机抽200个数据点作为观测到的数值\n",
    "obs_mu, obs_sigma = 0, 4\n",
    "observations = np.random.normal(obs_mu, obs_sigma, 200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [],
   "source": [
    "def likelihood(observations, infer_mu, infer_sigma):\n",
    "    # 定义似然函数, observations为观测到的数据点\n",
    "    # infer_mu, infer_sigma为推断的均值和标准差\n",
    "    product_ = 1\n",
    "    for obs in observations:\n",
    "        # 代入每一个数据点到我们假设的概率密度函数内, 并求它们的积\n",
    "        product_ *= stats.norm.pdf(obs, loc=infer_mu, scale=infer_sigma)\n",
    "    return product_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 我们定义一个参数的取值范围, 均值在(-0.5, 0.5)之间\n",
    "# 标准差在(3.5, 4.5)之间\n",
    "all_infer_mu = [i/10 for i in range(-5, 5)]\n",
    "all_infer_sigma = [i/10 for i in range(35, 45)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 求得每一个参数组合的似然值\n",
    "mle = []\n",
    "for infer_mu in all_infer_mu:\n",
    "    temp_lis = []\n",
    "    for infer_sigma in all_infer_sigma:\n",
    "        temp_lis.append(likelihood(observations, infer_mu, infer_sigma))\n",
    "    mle.append(temp_lis)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "data": [
        {
         "type": "surface",
         "x": [
          -0.5,
          -0.4,
          -0.3,
          -0.2,
          -0.1,
          0,
          0.1,
          0.2,
          0.3,
          0.4
         ],
         "y": [
          3.5,
          3.6,
          3.7,
          3.8,
          3.9,
          4,
          4.1,
          4.2,
          4.3,
          4.4
         ],
         "z": [
          [
           1.460825681631413e-249,
           1.0373120935883478e-248,
           4.682481547217632e-248,
           1.419451486742629e-247,
           3.03023899775314e-247,
           4.7476206183476214e-247,
           5.6591073457077994e-247,
           5.296104474699062e-247,
           4.000180909092284e-247,
           2.4982970345070237e-247
          ],
          [
           4.476409474673629e-249,
           2.9894940695276932e-248,
           1.275416701641574e-247,
           3.670235624951869e-247,
           7.467305457483984e-247,
           1.1189830134533918e-246,
           1.2798339607468397e-246,
           1.1526214309907195e-246,
           8.40009226031549e-247,
           5.074219710609222e-247
          ],
          [
           1.1650806670689444e-248,
           7.383549620589285e-248,
           3.0017958929467434e-247,
           8.262581349916492e-247,
           1.613409129439688e-246,
           2.327470419846075e-246,
           2.5697351244185605e-246,
           2.2396342461337547e-246,
           1.583114519199049e-246,
           9.294570610141049e-247
          ],
          [
           2.5755913849581866e-248,
           1.5628307442373045e-247,
           6.104684901647834e-247,
           1.6195186743637765e-246,
           3.0564596192454286e-246,
           4.2722635540242456e-246,
           4.580913843902494e-246,
           3.8853287510968715e-246,
           2.6777156728008803e-246,
           1.5354096355898816e-246
          ],
          [
           4.83607146694548e-248,
           2.8349012866247653e-247,
           1.0727496457009362e-246,
           2.7637870756392706e-246,
           5.076756973695156e-246,
           6.920621412681512e-246,
           7.25011540178241e-246,
           6.017813259175593e-246,
           4.06481179228702e-246,
           2.2874629048579498e-246
          ],
          [
           7.712643101726141e-248,
           4.407001339848886e-247,
           1.6288704370282895e-246,
           4.1064979727080796e-246,
           7.393458592634441e-246,
           9.893394746319798e-246,
           1.0187479491605617e-245,
           8.321658792255388e-246,
           5.537838366397335e-246,
           3.0733974441126817e-246
          ],
          [
           1.0447407591638561e-247,
           5.87121076092514e-247,
           2.137114232999409e-246,
           5.312354564801568e-246,
           9.440662565341089e-246,
           1.2481269857029873e-245,
           1.2709182264773008e-245,
           1.0274042676853264e-245,
           6.771173818490415e-246,
           3.7240736313842286e-246
          ],
          [
           1.2020114932797596e-247,
           6.703342433119301e-247,
           2.42282455330681e-246,
           5.983439501146988e-246,
           1.0569412905956128e-245,
           1.3895858986836018e-245,
           1.40765912878501e-245,
           1.1324866440591987e-245,
           7.430388161429455e-246,
           4.0696087659692717e-246
          ],
          [
           1.1746364697984904e-247,
           6.558951005692979e-247,
           2.3733906647249843e-246,
           5.867636000603116e-246,
           1.0375112463729928e-245,
           1.3652909555156847e-245,
           1.3842241650741372e-245,
           1.1145128373283335e-245,
           7.317839732550941e-246,
           4.0107161668927876e-246
          ],
          [
           9.749741907642282e-248,
           5.499923069240653e-247,
           2.0089518483418072e-246,
           5.009839752459894e-246,
           8.929524248058134e-246,
           1.1837996790456628e-245,
           1.2084936832477347e-245,
           9.792584422798124e-246,
           6.468121041765527e-246,
           3.56472526918372e-246
          ]
         ]
        }
       ],
       "layout": {
        "scene": {
         "xaxis": {
          "title": "mean"
         },
         "yaxis": {
          "title": "sigma"
         },
         "zaxis": {
          "title": "likelihood"
         }
        },
        "title": "Likelihood"
       }
      },
      "text/html": [
       "<div id=\"cc3ffd98-82f6-466c-a8a5-0440824d0070\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"cc3ffd98-82f6-466c-a8a5-0440824d0070\", [{\"type\": \"surface\", \"x\": [-0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4], \"y\": [3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4], \"z\": [[1.460825681631413e-249, 1.0373120935883478e-248, 4.682481547217632e-248, 1.419451486742629e-247, 3.03023899775314e-247, 4.7476206183476214e-247, 5.6591073457077994e-247, 5.296104474699062e-247, 4.000180909092284e-247, 2.4982970345070237e-247], [4.476409474673629e-249, 2.9894940695276932e-248, 1.275416701641574e-247, 3.670235624951869e-247, 7.467305457483984e-247, 1.1189830134533918e-246, 1.2798339607468397e-246, 1.1526214309907195e-246, 8.40009226031549e-247, 5.074219710609222e-247], [1.1650806670689444e-248, 7.383549620589285e-248, 3.0017958929467434e-247, 8.262581349916492e-247, 1.613409129439688e-246, 2.327470419846075e-246, 2.5697351244185605e-246, 2.2396342461337547e-246, 1.583114519199049e-246, 9.294570610141049e-247], [2.5755913849581866e-248, 1.5628307442373045e-247, 6.104684901647834e-247, 1.6195186743637765e-246, 3.0564596192454286e-246, 4.2722635540242456e-246, 4.580913843902494e-246, 3.8853287510968715e-246, 2.6777156728008803e-246, 1.5354096355898816e-246], [4.83607146694548e-248, 2.8349012866247653e-247, 1.0727496457009362e-246, 2.7637870756392706e-246, 5.076756973695156e-246, 6.920621412681512e-246, 7.25011540178241e-246, 6.017813259175593e-246, 4.06481179228702e-246, 2.2874629048579498e-246], [7.712643101726141e-248, 4.407001339848886e-247, 1.6288704370282895e-246, 4.1064979727080796e-246, 7.393458592634441e-246, 9.893394746319798e-246, 1.0187479491605617e-245, 8.321658792255388e-246, 5.537838366397335e-246, 3.0733974441126817e-246], [1.0447407591638561e-247, 5.87121076092514e-247, 2.137114232999409e-246, 5.312354564801568e-246, 9.440662565341089e-246, 1.2481269857029873e-245, 1.2709182264773008e-245, 1.0274042676853264e-245, 6.771173818490415e-246, 3.7240736313842286e-246], [1.2020114932797596e-247, 6.703342433119301e-247, 2.42282455330681e-246, 5.983439501146988e-246, 1.0569412905956128e-245, 1.3895858986836018e-245, 1.40765912878501e-245, 1.1324866440591987e-245, 7.430388161429455e-246, 4.0696087659692717e-246], [1.1746364697984904e-247, 6.558951005692979e-247, 2.3733906647249843e-246, 5.867636000603116e-246, 1.0375112463729928e-245, 1.3652909555156847e-245, 1.3842241650741372e-245, 1.1145128373283335e-245, 7.317839732550941e-246, 4.0107161668927876e-246], [9.749741907642282e-248, 5.499923069240653e-247, 2.0089518483418072e-246, 5.009839752459894e-246, 8.929524248058134e-246, 1.1837996790456628e-245, 1.2084936832477347e-245, 9.792584422798124e-246, 6.468121041765527e-246, 3.56472526918372e-246]]}], {\"title\": \"Likelihood\", \"scene\": {\"xaxis\": {\"title\": \"mean\"}, \"yaxis\": {\"title\": \"sigma\"}, \"zaxis\": {\"title\": \"likelihood\"}}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\"})});</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<div id=\"cc3ffd98-82f6-466c-a8a5-0440824d0070\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"cc3ffd98-82f6-466c-a8a5-0440824d0070\", [{\"type\": \"surface\", \"x\": [-0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4], \"y\": [3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4], \"z\": [[1.460825681631413e-249, 1.0373120935883478e-248, 4.682481547217632e-248, 1.419451486742629e-247, 3.03023899775314e-247, 4.7476206183476214e-247, 5.6591073457077994e-247, 5.296104474699062e-247, 4.000180909092284e-247, 2.4982970345070237e-247], [4.476409474673629e-249, 2.9894940695276932e-248, 1.275416701641574e-247, 3.670235624951869e-247, 7.467305457483984e-247, 1.1189830134533918e-246, 1.2798339607468397e-246, 1.1526214309907195e-246, 8.40009226031549e-247, 5.074219710609222e-247], [1.1650806670689444e-248, 7.383549620589285e-248, 3.0017958929467434e-247, 8.262581349916492e-247, 1.613409129439688e-246, 2.327470419846075e-246, 2.5697351244185605e-246, 2.2396342461337547e-246, 1.583114519199049e-246, 9.294570610141049e-247], [2.5755913849581866e-248, 1.5628307442373045e-247, 6.104684901647834e-247, 1.6195186743637765e-246, 3.0564596192454286e-246, 4.2722635540242456e-246, 4.580913843902494e-246, 3.8853287510968715e-246, 2.6777156728008803e-246, 1.5354096355898816e-246], [4.83607146694548e-248, 2.8349012866247653e-247, 1.0727496457009362e-246, 2.7637870756392706e-246, 5.076756973695156e-246, 6.920621412681512e-246, 7.25011540178241e-246, 6.017813259175593e-246, 4.06481179228702e-246, 2.2874629048579498e-246], [7.712643101726141e-248, 4.407001339848886e-247, 1.6288704370282895e-246, 4.1064979727080796e-246, 7.393458592634441e-246, 9.893394746319798e-246, 1.0187479491605617e-245, 8.321658792255388e-246, 5.537838366397335e-246, 3.0733974441126817e-246], [1.0447407591638561e-247, 5.87121076092514e-247, 2.137114232999409e-246, 5.312354564801568e-246, 9.440662565341089e-246, 1.2481269857029873e-245, 1.2709182264773008e-245, 1.0274042676853264e-245, 6.771173818490415e-246, 3.7240736313842286e-246], [1.2020114932797596e-247, 6.703342433119301e-247, 2.42282455330681e-246, 5.983439501146988e-246, 1.0569412905956128e-245, 1.3895858986836018e-245, 1.40765912878501e-245, 1.1324866440591987e-245, 7.430388161429455e-246, 4.0696087659692717e-246], [1.1746364697984904e-247, 6.558951005692979e-247, 2.3733906647249843e-246, 5.867636000603116e-246, 1.0375112463729928e-245, 1.3652909555156847e-245, 1.3842241650741372e-245, 1.1145128373283335e-245, 7.317839732550941e-246, 4.0107161668927876e-246], [9.749741907642282e-248, 5.499923069240653e-247, 2.0089518483418072e-246, 5.009839752459894e-246, 8.929524248058134e-246, 1.1837996790456628e-245, 1.2084936832477347e-245, 9.792584422798124e-246, 6.468121041765527e-246, 3.56472526918372e-246]]}], {\"title\": \"Likelihood\", \"scene\": {\"xaxis\": {\"title\": \"mean\"}, \"yaxis\": {\"title\": \"sigma\"}, \"zaxis\": {\"title\": \"likelihood\"}}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\"})});</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 进行似然函数的3D可视化\n",
    "data = [go.Surface(x=all_infer_mu, y=all_infer_sigma, z=mle)]\n",
    "layout = go.Layout(title=\"Likelihood\", scene={\"xaxis\": {'title': \"mean\"}, \"yaxis\": {\"title\": \"sigma\"},\"zaxis\": {\"title\": \"likelihood\"}})\n",
    "fig = go.Figure(data=data, layout=layout)\n",
    "iplot(fig)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们看到上图中的最高点$\\mu \\approx 0, \\ \\sigma \\approx 4$, 是产生观测数据的真实概率分布的参数, 但是似然函数输出的值极小, 最高的值仅有$1*10^{-245}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "对数似然值$(log \\ likelihood)$: \n",
    "我们对似然函数取$\\log$, 就得到了对数似然函数:   \n",
    "$$\\mathcal {L}(\\mu ,\\sigma \\mid X)=\\sum _{i=1}^{N}\\log P(x_{i}\\mid \\mu,\\sigma)$$\n",
    "为什么要对似然函数取对数?  \n",
    "1. 首先原本的似然函数是很多条件概率的乘积, 我们在找极大值的时候需要求似然函数的导数, 而乘积的导数不方便计算, 取对数可以吧乘除变成加减;\n",
    "2. 对似然函数取对数, 原本函数的极大值的位置没有改变;\n",
    "3. 如果观测到的数据点比较多, 原始似然函数的乘积可能非常接近于0, 甚至超出计算机的储存位数限制, 这样就全变成0了, 取对数可以把接近于$0$的数变成很大的负数, 也就是把原本似然函数的取值范围从$0$到$1$扩展到了$-\\infty$到$0$, 方便了计算.   \n",
    "   \n",
    "我们下面对$log \\ likelihood$进行3D可视化, 可看到原始的似然函数和对数似然函数的最高点是一样的位置:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [],
   "source": [
    "def log_likelihood(observations, infer_mu, infer_sigma):\n",
    "    sum_ = 0\n",
    "    for obs in observations:\n",
    "        sum_ += stats.norm.logpdf(obs, loc=infer_mu, scale=infer_sigma)\n",
    "    return sum_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "mle = []\n",
    "for infer_mu in all_infer_mu:\n",
    "    temp_lis = []\n",
    "    for infer_sigma in all_infer_sigma:\n",
    "        temp_lis.append(log_likelihood(observations, infer_mu, infer_sigma))\n",
    "    mle.append(temp_lis)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "data": [
        {
         "type": "surface",
         "x": [
          -0.5,
          -0.4,
          -0.3,
          -0.2,
          -0.1,
          0,
          0.1,
          0.2,
          0.3,
          0.4
         ],
         "y": [
          3.5,
          3.6,
          3.7,
          3.8,
          3.9,
          4,
          4.1,
          4.2,
          4.3,
          4.4
         ],
         "z": [
          [
           -572.9646863442881,
           -571.0044702204175,
           -569.4972748479921,
           -568.3882474494818,
           -567.6298764759722,
           -567.180874399439,
           -567.0052518025246,
           -567.0715464239934,
           -567.3521783821593,
           -567.8229086559649
          ],
          [
           -571.8448668869746,
           -569.9459988969535,
           -568.4952450194975,
           -567.4382621065395,
           -566.727983750654,
           -566.3235126274345,
           -566.1892025251844,
           -566.2938940230815,
           -566.6102752803693,
           -567.1143452080269
          ],
          [
           -570.8883127357834,
           -569.041848561144,
           -567.6393072289874,
           -566.6267809187221,
           -565.9575834645206,
           -565.5911508554285,
           -565.4921300473679,
           -565.6296203069767,
           -565.9765387551076,
           -566.5090875452121
          ],
          [
           -570.095023890715,
           -568.292019212989,
           -566.9294614764602,
           -565.9538038860285,
           -565.318675617572,
           -564.9837890834228,
           -564.9140343690765,
           -565.0787252756792,
           -565.450968806374,
           -566.0071356675214
          ],
          [
           -569.4650003517685,
           -567.6965108524885,
           -566.3657077619174,
           -565.41933100846,
           -564.811260209808,
           -564.501427311417,
           -564.4549154903077,
           -564.6412089291887,
           -565.0335654341679,
           -565.6084895749547
          ],
          [
           -568.998242118945,
           -567.2553234796419,
           -565.9480460853588,
           -565.023362286016,
           -564.4353372412288,
           -564.1440655394114,
           -564.1147734110646,
           -564.3170712675054,
           -564.7243286384894,
           -565.3131492675119
          ],
          [
           -568.6947491922439,
           -566.9684570944495,
           -565.6764764467837,
           -564.7658977186967,
           -564.1909067118343,
           -563.9117037674058,
           -563.8936081313446,
           -564.1063122906297,
           -564.5232584193385,
           -565.1211147451934
          ],
          [
           -568.5545215716648,
           -566.8359116969119,
           -565.5509988461928,
           -564.6469373065023,
           -564.0779686216246,
           -563.8043419954001,
           -563.7914196511487,
           -564.0089319985611,
           -564.430354776717,
           -565.0323860079986
          ],
          [
           -568.5775592572089,
           -566.8576872870285,
           -565.5716132835861,
           -564.6664810494316,
           -564.0965229705998,
           -563.8219802233942,
           -563.8082079704772,
           -564.0249303912991,
           -564.4456177106218,
           -565.0469630559279
          ],
          [
           -568.763862248875,
           -567.0337838647996,
           -565.7383197589627,
           -564.8245289474871,
           -564.2465697587592,
           -563.9646184513889,
           -563.9439730893296,
           -564.1543074688458,
           -564.5690472210554,
           -565.164845888981
          ]
         ]
        }
       ],
       "layout": {
        "scene": {
         "xaxis": {
          "title": "mean"
         },
         "yaxis": {
          "title": "sigma"
         },
         "zaxis": {
          "title": "likelihood"
         }
        },
        "title": "Log Likelihood"
       }
      },
      "text/html": [
       "<div id=\"950446c6-e1c9-4748-b730-7eeaa58d9f4b\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"950446c6-e1c9-4748-b730-7eeaa58d9f4b\", [{\"type\": \"surface\", \"x\": [-0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4], \"y\": [3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4], \"z\": [[-572.9646863442881, -571.0044702204175, -569.4972748479921, -568.3882474494818, -567.6298764759722, -567.180874399439, -567.0052518025246, -567.0715464239934, -567.3521783821593, -567.8229086559649], [-571.8448668869746, -569.9459988969535, -568.4952450194975, -567.4382621065395, -566.727983750654, -566.3235126274345, -566.1892025251844, -566.2938940230815, -566.6102752803693, -567.1143452080269], [-570.8883127357834, -569.041848561144, -567.6393072289874, -566.6267809187221, -565.9575834645206, -565.5911508554285, -565.4921300473679, -565.6296203069767, -565.9765387551076, -566.5090875452121], [-570.095023890715, -568.292019212989, -566.9294614764602, -565.9538038860285, -565.318675617572, -564.9837890834228, -564.9140343690765, -565.0787252756792, -565.450968806374, -566.0071356675214], [-569.4650003517685, -567.6965108524885, -566.3657077619174, -565.41933100846, -564.811260209808, -564.501427311417, -564.4549154903077, -564.6412089291887, -565.0335654341679, -565.6084895749547], [-568.998242118945, -567.2553234796419, -565.9480460853588, -565.023362286016, -564.4353372412288, -564.1440655394114, -564.1147734110646, -564.3170712675054, -564.7243286384894, -565.3131492675119], [-568.6947491922439, -566.9684570944495, -565.6764764467837, -564.7658977186967, -564.1909067118343, -563.9117037674058, -563.8936081313446, -564.1063122906297, -564.5232584193385, -565.1211147451934], [-568.5545215716648, -566.8359116969119, -565.5509988461928, -564.6469373065023, -564.0779686216246, -563.8043419954001, -563.7914196511487, -564.0089319985611, -564.430354776717, -565.0323860079986], [-568.5775592572089, -566.8576872870285, -565.5716132835861, -564.6664810494316, -564.0965229705998, -563.8219802233942, -563.8082079704772, -564.0249303912991, -564.4456177106218, -565.0469630559279], [-568.763862248875, -567.0337838647996, -565.7383197589627, -564.8245289474871, -564.2465697587592, -563.9646184513889, -563.9439730893296, -564.1543074688458, -564.5690472210554, -565.164845888981]]}], {\"title\": \"Log Likelihood\", \"scene\": {\"xaxis\": {\"title\": \"mean\"}, \"yaxis\": {\"title\": \"sigma\"}, \"zaxis\": {\"title\": \"likelihood\"}}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\"})});</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<div id=\"950446c6-e1c9-4748-b730-7eeaa58d9f4b\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"950446c6-e1c9-4748-b730-7eeaa58d9f4b\", [{\"type\": \"surface\", \"x\": [-0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4], \"y\": [3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4], \"z\": [[-572.9646863442881, -571.0044702204175, -569.4972748479921, -568.3882474494818, -567.6298764759722, -567.180874399439, -567.0052518025246, -567.0715464239934, -567.3521783821593, -567.8229086559649], [-571.8448668869746, -569.9459988969535, -568.4952450194975, -567.4382621065395, -566.727983750654, -566.3235126274345, -566.1892025251844, -566.2938940230815, -566.6102752803693, -567.1143452080269], [-570.8883127357834, -569.041848561144, -567.6393072289874, -566.6267809187221, -565.9575834645206, -565.5911508554285, -565.4921300473679, -565.6296203069767, -565.9765387551076, -566.5090875452121], [-570.095023890715, -568.292019212989, -566.9294614764602, -565.9538038860285, -565.318675617572, -564.9837890834228, -564.9140343690765, -565.0787252756792, -565.450968806374, -566.0071356675214], [-569.4650003517685, -567.6965108524885, -566.3657077619174, -565.41933100846, -564.811260209808, -564.501427311417, -564.4549154903077, -564.6412089291887, -565.0335654341679, -565.6084895749547], [-568.998242118945, -567.2553234796419, -565.9480460853588, -565.023362286016, -564.4353372412288, -564.1440655394114, -564.1147734110646, -564.3170712675054, -564.7243286384894, -565.3131492675119], [-568.6947491922439, -566.9684570944495, -565.6764764467837, -564.7658977186967, -564.1909067118343, -563.9117037674058, -563.8936081313446, -564.1063122906297, -564.5232584193385, -565.1211147451934], [-568.5545215716648, -566.8359116969119, -565.5509988461928, -564.6469373065023, -564.0779686216246, -563.8043419954001, -563.7914196511487, -564.0089319985611, -564.430354776717, -565.0323860079986], [-568.5775592572089, -566.8576872870285, -565.5716132835861, -564.6664810494316, -564.0965229705998, -563.8219802233942, -563.8082079704772, -564.0249303912991, -564.4456177106218, -565.0469630559279], [-568.763862248875, -567.0337838647996, -565.7383197589627, -564.8245289474871, -564.2465697587592, -563.9646184513889, -563.9439730893296, -564.1543074688458, -564.5690472210554, -565.164845888981]]}], {\"title\": \"Log Likelihood\", \"scene\": {\"xaxis\": {\"title\": \"mean\"}, \"yaxis\": {\"title\": \"sigma\"}, \"zaxis\": {\"title\": \"likelihood\"}}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\"})});</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data = [go.Surface(x=all_infer_mu, y=all_infer_sigma, z=mle)]\n",
    "layout = go.Layout(title=\"Log Likelihood\", scene={\"xaxis\": {'title': \"mean\"}, \"yaxis\": {\"title\": \"sigma\"},\"zaxis\": {\"title\": \"likelihood\"}})\n",
    "fig = go.Figure(data=data, layout=layout)\n",
    "iplot(fig)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
